package usercheck;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LoginCheck
 */
public class VoteCheck extends HttpServlet {
	private static final long serialVersionUID = 1L;
	int info1 = 0, info2 = 0, info3 = 0, info4 = 0, info5 = 0, info6 = 0;

	public VoteCheck() {
		super();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		String t1 = request.getParameter("t1");
		String t2 = request.getParameter("t2");
		String t3 = request.getParameter("t3");
		String t4 = request.getParameter("t4");
		String t5 = request.getParameter("t5");
		String t6 = request.getParameter("t6");
		if(t1!=null&&t1.equals("on")) {
			info1 += 1;
		}
		if(t2!=null&&t2.equals("on")) {
			info2 += 1;
		}
		if(t3!=null&&t3.equals("on")) {
			info3 += 1;
		}
		if(t4!=null&&t4.equals("on")) {
			info4 += 1;
		}
		if(t5!=null&&t5.equals("on")) {
			info5 += 1;
		}
		if(t6!=null&&t6.equals("on")) {
			info6 += 1;
		}
		ServletContext context = this.getServletContext();
		context.setAttribute("info1", info1);
		context.setAttribute("info2", info2);
		context.setAttribute("info3", info3);
		context.setAttribute("info4", info4);
		context.setAttribute("info5", info5);
		context.setAttribute("info6", info6);
		response.sendRedirect("index.jsp");
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
